package com.example.foobar.dao.service.impl;

import com.example.foobar.entity.DaQrcodeRecords;
import com.example.foobar.mapper.DaQrcodeRecordsMapper;
import com.example.foobar.dao.service.DaQrcodeRecordsDaoService;
import com.example.foobar.param.DaQrcodeRecordsPageParam;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

/**
 *  服务实现类
 *
 * @author 郑英奔
 * @since 2021-07-15
 */
@Slf4j
@Service
public class DaQrcodeRecordsDaoServiceImpl extends BaseServiceImpl<DaQrcodeRecordsMapper, DaQrcodeRecords> implements DaQrcodeRecordsDaoService {

    @Autowired
    private DaQrcodeRecordsMapper daQrcodeRecordsMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean saveDaQrcodeRecords(DaQrcodeRecords daQrcodeRecords)  {
        return super.save(daQrcodeRecords);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean updateDaQrcodeRecords(DaQrcodeRecords daQrcodeRecords)  {
        return super.updateById(daQrcodeRecords);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteDaQrcodeRecords(Long id)  {
        return super.removeById(id);
    }

    @Override
    public Paging<DaQrcodeRecords> getDaQrcodeRecordsPageList(DaQrcodeRecordsPageParam daQrcodeRecordsPageParam)  {
        Page<DaQrcodeRecords> page = new PageInfo<>(daQrcodeRecordsPageParam, OrderItem.desc(getLambdaColumn(DaQrcodeRecords::getCreateTime)));
        LambdaQueryWrapper<DaQrcodeRecords> wrapper = new LambdaQueryWrapper<>();
        IPage<DaQrcodeRecords> iPage = daQrcodeRecordsMapper.selectPage(page, wrapper);
        return new Paging<DaQrcodeRecords>(iPage);
    }

}
